<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title></title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/css/bootstrap-responsive.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/ckform.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/common.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.min.js?v=2.1.4"></script>
<script>
	 $(function(){
         getSmallCategory();
		 $(document).on("click",".delbtn",function(event){
             var typeid=$(this).parents("tr").children().eq(0).text();
             $.ajax({
                 url:"${pageContext.request.contextPath}/btype/deleteSubType",
                 type:"post",
                 data:{"typeid":typeid},
                 dataType:"json",
                 cache:false,
                 success:function(rs){
                      if(rs.status==200){
                          alert(rs.msg);
                          getSmallCategory();
					  }else{
                          alert(rs.msg);
					  }
				 }
			 });
		 });
	 })
     function getSmallCategory() {

         $.ajax({
             url:"${pageContext.request.contextPath}/btype/getSmallList",
             type:"post",
             data:{"typeid":${typeid}},
             dataType:"json",
             cache:false,
             success:function(rs){

                 $("#tbody").empty();
                 $.each(rs,function(index,element){
                     var tr=" <tr>\n" +
							       "<td style='display:none'>"+element.typeid+"</td>"+
                         "\t\t\t   <td>"+element.typename+"</td>\n" +
                         "\t\t\t   <td>"+element.typedes+"</td>\n" +
                         "\t\t\t   <td>\n" +
                         "\t\t\t\t   <button type=\"submit\" class='delbtn'>删除</button>&nbsp;&nbsp;<button type=\"submit\" class='updatebtn'>修改</button>\n" +
                         "\t\t\t   </td>\n" +
                         "\t\t   </tr>";
                     $("#tbody").append(tr);
				 })
             }
         });

     }
</script>

<style type="text/css">
body {font-size: 20px;
	padding-bottom: 40px;
	background-color: #e9e7ef;
}

.sidebar-nav {
	padding: 9px 0;
}

@media ( max-width : 980px) {
	/* Enable use of floated navbar text */
	.navbar-text.pull-right {
		float: none;
		padding-left: 5px;
		padding-right: 5px;
	}
}
</style>
</head>
<body>
	<form class="form-inline definewidth m20" action="#" method="get">
		 <font color="#777777"><strong>小类信息：</strong></font> 
		
	</form>
	<table class="table table-bordered table-hover definewidth m10">
		<thead>
			<tr>
				<th>小类名称</th>
			    <th>介绍</th>
				<th>删除</th>
			</tr>
		</thead>
		<tbody id="tbody">
		   <%--存放数据行： --%>
		   <tr>
			   <td>娱乐</td>
			   <td>阿斯顿啥放</td>
			   <td>
				   <button type="submit">删除</button>
			   </td>
		   </tr>
		</tbody>

	</table>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type="button"  id="addnew">
			<a href="${pageContext.request.contextPath}/btype/subtype_add?typeid=${typeid}">添加小类</a>
	  </button>
</body>

</html>
